// miniprogram/pages/subPages/chuhuoDetail/chuhuoDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    goodsImg: [],
    goods: [
      {
        id: "goods01",
        price: 22.99,
        name: '耳机',
        num: 100,
        imgSrc: "https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1678948314,1083480950&fm=26&gp=0.jpg"
      },
      {
        id: "goods02",
        price: 22.99,
        name: '耳机',
        num: 100,
        imgSrc: "https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1728577482,2585850803&fm=26&gp=0.jpg"
      },
      {
        id: "goods03",
        price: 22.99,
        name: '耳机',
        num: 100,
        imgSrc: "https://dss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2443852970,3855863032&fm=26&gp=0.jpg"
      },
      {
        id: "goods04",
        price: 22.99,
        name: '耳机',
        num: 100,
        imgSrc: "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=975216563,2695721503&fm=11&gp=0.jpg"
      },
      {
        id: "goods05",
        price: 22.99,
        name: '耳机',
        num: 100,
        imgSrc:"https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1706397442,4020316585&fm=26&gp=0.jpg"
      }                                                                     
    ],
    proofUrl:[]
  },

  // 放大图片
  scaleImg(e){
    var arr=e.currentTarget.dataset.arr
    console.log(arr)
    wx.previewImage({
      urls: [...arr],
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
// 上传
  upload:function(){
    var that=this
    wx.chooseImage({
      success: function(res) {
        console.log(res)
        var length=res.tempFiles.length;
        for(var i=0;i<length;i++)
        {
          that.data.proofUrl.push(res.tempFiles[i].path)
        }
        that.setData({
          proofUrl:that.data.proofUrl
        })
        console.log(that.data.proofUrl)
      },
    })  
  },
  /**
   * 
   * 
   * 
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    var length = this.data.goods.length;
    for (var i = 0; i < length; i++) {
      this.data.goodsImg.push(this.data.goods[i].imgSrc)
    }
    this.setData({
      goodsImg: this.data.goodsImg
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})